<?php

    require ( 'init.inc.php' );
    require ( 'checkadmin.inc.php');
    require ( __COMM_PATH . 'pagecontrol.inc.php' );
    require ( __COMM_PATH . 'checkform.func.php' );
    require ( __CLASS_PATH . 'page_edit.class.php' );

    // -------------------------------------------------------
    // 接收传递过来的变量
    // -------------------------------------------------------
    $action = $_REQUEST["action"];
    $id     = addslashes($_REQUEST["id"]);

    // -------------------------------------------------------
    // 页面基本设置
    // -------------------------------------------------------
    $page_title   = $ptitle["job_add"];                        // 页面标题
    $page_type    = "add";                                      // 页面类型
    $display_page = "job_edit.htm";                            // Smarty 模板页面
    $table_name   = "{$tablepre}jobs";                          // 表名
    $condition    = "";             // 查询条件
    $back_page    = "job_list.php?sortby={$_GET['sortby']}&oexp={$_GET['oexp']}&page={$_GET['page']}&classid={$classid}&keyword={$_GET['keyword']}";

    // -------------------------------------------------------
    // 保存编辑数据
    // -------------------------------------------------------
    if ($action=="submit") {
        $jobs = dhtmlspecialchars(check_empty($_POST["jobs"],$clang[jobs]));
        $number = dhtmlspecialchars(check_numeric($_POST["number"],$clang[jobs_number]));
        $place = dhtmlspecialchars($_POST["place"]);
        $salary = dhtmlspecialchars($_POST["salary"]);
        $expires = dhtmlspecialchars($_POST["expires"]);
        $posttime = date ("Y-m-d H:i:s",strtotime($_POST["posttime"]));
        $resbility = dhtmlspecialchars($_POST["resbility"]);
        $require = dhtmlspecialchars($_POST["require"]);	
        $status = dhtmlspecialchars(check_numeric($_POST["status"],$clang[news_confirm])); 
		
        $fields_arr = array( 
            "jobs" => $jobs,
            "number" => $number,
            "place" => $place,
            "salary" => $salary,
            "expires" => $expires,
            "posttime" => $posttime,
            "resbility" => $resbility,
            "posttime" => $posttime,
            "require" => $require,
            "status" => $status
        );
    }

    // -------------------------------------------------------
    // 解析基本信息
    // -------------------------------------------------------
    $tpl->assign("isnew", 0);
    $tpl->assign("confirm", 1);
    $tpl->assign('posttime', date("Y-m-d H:i:s"));
    $tpl->assign('author', $_SESSION["AdminUser"]);

    // -------------------------------------------------------
    // 执行页面处理
    // -------------------------------------------------------
    show_page_head($page_type, $page_title);
    $pedit = new PageEdit($page_title, $back_page, $page_type); // 实例化一个编辑页面
    $pedit->SetParam($table_name, $condition);                  // 设置数据库基本参数，查询条件
    $pedit->InsertData($fields_arr);                            // 更新数据
    $pedit->TplParse($display_page);                            // 自动解析相关数据到 Smarty 模板
    show_page_foot();
    $db->close();
?>